/******FIGURE IV: EFFECTS BY MEDIA COVERAGE***********/

/*******RUN ANALYSIS**********/
use ../data/main_distance.dta, clear

reghdfe reg MEDIAsht_cb MEDIAsht_pt* , absorb(cb pop_dec#elec_yr CBG#elec_yr) cluster(CBG)
parmest, saving(../estimates/distance_media, replace)
outreg2 using ../output/table_distance.xls, append stats(coef se) ctitle(`y') dec(3) alpha(.01, .05, .10) addtext(model, media) symbol(***, **, *) excel side

reghdfe reg NOMEDIAsht_cb NOMEDIAsht_pt* , absorb(cb pop_dec#elec_yr CBG#elec_yr) cluster(CBG)
parmest, saving(../estimates/distance_nomedia, replace)
outreg2 using ../output/table_distance.xls, append stats(coef se) ctitle(`y') dec(3) alpha(.01, .05, .10) addtext(model, nomedia) symbol(***, **, *) excel side

/*******CREATE FIGURES*********/
local color1 = "navy"
local color2 = "maroon*0.65"
local symbol1 = "circle"
local symbol2 = "diamond"

local lwidth = "medthick"
local msize = "medlarge"
local estin "postmarket"
local tabout "postmarket"
local tsize = "medlarge"
local labsize = "medium"
local titlesize = "vlarge"

use "../estimates/distance_media", clear
gen media =1
append using "../estimates/distance_nomedia"
replace media = 0 if media==.

gen dist = real(substr(parm, -3, 3))
replace dist = real(substr(parm, -2, 2)) if dist==.
replace dist = 0 if dist==.

replace dist = 80 if parm=="_cons"
replace estimate = 0 if parm=="_cons"
replace min95 = 0 if parm=="_cons"
replace max95 = 0 if parm=="_cons"

replace dist = 210 if strpos(parm, "ov200")!=0

gen dist1 = dist
replace dist1 = dist+1.5 if media==0
replace dist1 = dist-1.5 if media==1

#delimit ;
graph twoway (scatter est dist1 if media==1,  msymbol(`symbol1') mcolor(`color1') ) (rcap min95 max95 dist1 if media==1, msize(vtiny) lcolor(`color1')) 
(scatter est dist1 if media==0,   msymbol(`symbol2') mcolor(`color2')) (rcap min95 max95 dist1 if media==0, msize(vtiny) lcolor(`color2')), 
xlabel(0 "In CB" 10 "0.1" 20 "0.2" 30 "0.3" 40 "0.4" 50 "0.5" 60 "0.6" 70 "0.7" 80 "0.8" 90 "0.9" 100 "1.0"
110 "1.1" 120 "1.2" 130 "1.3" 140 "1.4" 150 "1.5" 160 "1.6" 170 "1.7" 180 "1.8" 190 "1.9" 200 "2.0" 210 ">2.0", labsize(`labsize')) xsize(16) ysize(7)
ytitle("Registrations", size(`tsize'))
yline(0, lcolor(red))
ylabel(-10(10)20) yscale(range(-10 20))
xtitle("Distance from police killing (miles)", size(`tsize'))
legend(order(1 3) label(1 "Media") label(3 "No Media") size(`tsize')) ///
plotregion(fcolor(white)) graphregion(fcolor(white) lcolor(white)) bgcolor(white);
graph export ../output/fig4_media.png, replace width(12000);
graph export ../output/fig4_media.eps, replace ;

#delimit cr
